#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
//	system("start https://www.lanqiao.cn/problems/16978/learning/");

    vector<int> cnt = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    string s, t;
    cin >> s >> t;

    int cnt1, cnt2;
    cnt1 = cnt2 = 0;

    for(auto i : s)	cnt1 += cnt[i - '0'];
    for(auto i : t)	cnt2 += cnt[i - '0'];

    cout << abs(cnt2 - cnt1);

    return 0;
}

